//
//  RankingListVc.swift
//  DoctorVisits
//
//  Created by lanou3g on 16/2/29.
//  Copyright © 2016年 SHH. All rights reserved.
//

import UIKit

class RankingListVc: UIViewController,UITableViewDelegate,UITableViewDataSource {

    //声明一个scollView视窗
    var pageView:UIScrollView?

    //声明一个tableView电影视窗
    var rankingListMovie:RankingListTV?
    //声明一个tableView电视剧视窗
    var rankingListSeries:RankingListTV?
    //声明一个tableView动漫视窗
    var rankingListAnime:RankingListTV?
    //声明一个tableView综艺视窗
    var rankingListVariety:RankingListTV?
    
    //声明四个button用来跳转到详情界面
    var movieBut:UIButton?    //电影按钮
    var seriesBut:UIButton?   //连续剧按钮
    var animeBut:UIButton?       //动漫按钮
    var varietyBut:UIButton?     //综艺按钮
    
    override func viewDidLoad() {
        super.viewDidLoad()
        //添加视图
        addView()
    }

    
    
//添加视图
    func addView() {
        
    //创建整体scrollView页面
    self.pageView = UIScrollView(frame: self.view.frame)
    self.pageView?.contentSize = CGSize(width: self.view.frame.width, height: self.view.frame.height * 1.47)
    self.pageView?.backgroundColor = UIColor.blueColor()
        
    //创建四个分类tableView视窗并布局
        //电影
    self.rankingListMovie = RankingListTV(frame: CGRectMake(0, self.view.frame.height * 0.06, self.view.frame.width * 0.5 - 10, self.view.frame.height * 0.635))
    self.rankingListMovie?.separatorStyle = .None  //设置分割线样式
    self.rankingListMovie?.backgroundColor = UIColor.whiteColor()
    
        //电视剧
    self.rankingListSeries = RankingListTV(frame: CGRectMake((self.rankingListMovie?.frame.maxX)! + 20, (self.rankingListMovie?.frame.minY)!, (self.rankingListMovie?.frame.width)!, (self.rankingListMovie?.frame.height)!))
    self.rankingListSeries?.backgroundColor = UIColor.whiteColor()
    self.rankingListSeries?.separatorStyle = .None  //设置分割线样式
    self.view.addSubview(self.pageView!)
        
        //动漫
    self.rankingListAnime = RankingListTV(frame: CGRectMake((self.rankingListMovie?.frame.minX)!, (self.rankingListMovie?.frame.maxY)! + self.view.frame.height * 0.06, (self.rankingListMovie?.frame.width)!, (self.rankingListMovie?.frame.height)!))
    self.rankingListAnime?.backgroundColor = UIColor.whiteColor()
    self.rankingListAnime?.separatorStyle = .None
    
    
        //综艺
    self.rankingListVariety = RankingListTV(frame: CGRectMake((self.rankingListSeries?.frame.minX)!, (self.rankingListAnime?.frame.minY)!, (self.rankingListMovie?.frame.width)!, (self.rankingListMovie?.frame.height)!))
    self.rankingListVariety?.backgroundColor = UIColor.whiteColor()
    self.rankingListVariety?.separatorStyle = .None
    
        
        //电影按钮
    self.movieBut = UIButton(frame: CGRectMake((self.rankingListMovie?.frame.minX)!, (self.rankingListMovie?.frame.minY)! - self.view.frame.height * 0.06, (self.rankingListMovie?.frame.width)! * 0.5, self.view.frame.height * 0.06))
    self.movieBut?.backgroundColor = UIColor.grayColor()
    self.movieBut?.setTitle("电影", forState: UIControlState.Normal)
        
        //电视剧按钮
    self.seriesBut = UIButton(frame: CGRectMake((self.rankingListSeries?.frame.minX)!, (self.rankingListSeries?.frame.minY)! - self.view.frame.height * 0.06, (self.movieBut?.frame.width)!, (self.movieBut?.frame.height)!))
    self.seriesBut?.backgroundColor = UIColor.grayColor()
    self.seriesBut?.setTitle("电视剧", forState: UIControlState.Normal)
        
        //动漫按钮
    self.animeBut = UIButton(frame: CGRectMake((self.rankingListAnime?.frame.minX)!, (self.rankingListAnime?.frame.minY)! - self.view.frame.height * 0.06, (self.movieBut?.frame.width)!, (self.movieBut?.frame.height)!))
    self.animeBut?.setTitle("动漫", forState: UIControlState.Normal)
    self.animeBut?.backgroundColor = UIColor.grayColor()
        
        //综艺按钮
    self.varietyBut = UIButton(frame: CGRectMake((self.rankingListVariety?.frame.minX)!, (self.rankingListVariety?.frame.minY)! - self.view.frame.height * 0.06,(self.movieBut?.frame.width)!, (self.movieBut?.frame.height)!))
    self.varietyBut?.setTitle("综艺", forState: UIControlState.Normal)
    self.varietyBut?.backgroundColor = UIColor.grayColor()

        
        
    self.pageView!.addSubview(self.rankingListMovie!)
    self.pageView!.addSubview(self.rankingListSeries!)
    self.pageView!.addSubview(self.rankingListAnime!)
    self.pageView!.addSubview(self.rankingListVariety!)
    
    self.pageView!.addSubview(self.movieBut!)
    self.pageView!.addSubview(self.seriesBut!)
    self.pageView!.addSubview(self.animeBut!)
    self.pageView!.addSubview(self.varietyBut!)
    
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        
        
    }

    
//UITableView协议方法
    
    //设置行数
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
        
        return 10
        
    }
    
    //创建cell
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
        
        var cell = tableView.dequeueReusableCellWithIdentifier("CELL")
        cell = UITableViewCell()
        cell?.textLabel?.text = "测试"
        return cell!
    }
    
    //设置遍数
    func numberOfSectionsInTableView(tableView: UITableView) -> Int // Default is 1 if not implemented
    {
        return 1
    }
    
    
    //设置头标
    func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? // fixed font style. use custom view (UILabel) if you want something different
    {
        return "头标"
    }

    //设置脚标
    func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String?
    {
        return "脚标"
    }


    

}
